package site.yunnong.common.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import site.yunnong.common.entity.VideoRankEntity;
import site.yunnong.common.service.VideoRankService;
import site.yunnong.common.utils.PageUtils;
import site.yunnong.common.utils.R;



/**
 * 视频排行榜
 *
 * @author zhangjinghao
 * @email jhzhang9102@163.com
 * @date 2021-07-09 23:45:37
 */
@RestController
@RequestMapping("common/videorank")
public class VideoRankController {
    @Autowired
    private VideoRankService videoRankService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("common:videorank:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = videoRankService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("common:videorank:info")
    public R info(@PathVariable("id") Long id){
		VideoRankEntity videoRank = videoRankService.getById(id);

        return R.ok().put("videoRank", videoRank);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("common:videorank:save")
    public R save(@RequestBody VideoRankEntity videoRank){
		videoRankService.save(videoRank);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("common:videorank:update")
    public R update(@RequestBody VideoRankEntity videoRank){
		videoRankService.updateById(videoRank);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("common:videorank:delete")
    public R delete(@RequestBody Long[] ids){
		videoRankService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
